
<@override name="content">
<div class="panel panel-default ux-panel">
    <div class="panel-heading">
        <h3 class="panel-title">用户管理</h3>
    </div>

    <div class="panel-body">

        <form id="_queryPageForm">

            <div class="col-sm-3">
                <input type="text" name="username" class="form-control" placeholder="请输入用户登录名" value="${(queryEntity.username)!}"/>
            </div>
            <div class="col-sm-3">
                <select name="status" class="form-control" >
                    <option value="-1">所有</option>
                    <#list status as key,value>
                            <option value="${key}" <#if (queryEntity.status)?? && (queryEntity.status==key)>selected</#if> >${value}</option>
                    </#list>
                    </select>
            </div>
            <button type="button" class="btn btn-primary" onclick="doSearch()">搜索</button>

            <div class="ux-table-div" style="margin-top:15px;">
                <table class="table table-condensed">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>登录名</th>
                        <th>手机</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>

                    <tbody>
                    <#if (page.items)??>
                        <#list page.items as item>
                        <tr>
                            <td>${item.name!}</td>
                            <td>${item.username!}</td>
                            <td>${item.mobile!}</td>
                            <td>${item.statusName!}</td>
                            <td>
                                <a href="javascript:void(0)" onclick="toEdit(${item.id});">修改</a>
                            </td>
                        </tr>
                        </#list>
                    </#if>
                </tbody>
                </table>
            </div>

            <#if (page.pageTotalCount)?? && page.pageTotalCount gt 1>
                <ul class="pagination">
                    <input type="hidden" id="_id_pageNum" name="pageNum" value="${page.pageNum}"/>
                    <#list page.showNums as n>
                    <#if page.showDot && n_index == 6>
                    <li class="disabled"><a href="javascript:void(0)">...</a></li>
                        </#if>
                        <#if page.pageNum == n>
                        <li class="active"><a href="javascript:void(0);">${n}</a></li>
                        <#else>
                        <li><a href="javascript:void(0);" onclick="_queryPage('${n}');">${n}</a></li>
                    </#if>
                </#list>
                </ul>
            </#if>

        </form>

        <!-- 弹出层 -start -->
        <div class="modal" id="myModal" tabindex="-1" role="dialog" style="margin-top:5%;" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" >修改用户信息</h4>
                    </div>

                    <div class="modal-body">
                        <form id="myForm" class="form-horizontal" role="form" action="${base}/authUser/merge" method="POST">
                            <input type="hidden"  name="id" />

                            <div class="form-group">
                                <label class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  readonly="readonly" name="name" >
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">登录名</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" readonly="readonly"  name="username"  >
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态</label>
                                <div class="col-sm-8">
                                    <select id="status" name="status" class="form-control" >
                                        <#list status as key,value>
                                        <option value="${key}">${value}</option>
                                    </#list>
                                    </select>
                                </div>
                            </div>

                        </form>
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" onclick="doSubmit()">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- 弹出层 -end -->

    </div><!-- panel-body end -->
</div><!-- panel end -->

    <script type="text/javascript">
		function toEdit(id){
			$.ajax({
				url:'${base}/authUser/get',
			    dataType:'json',
			    data:{"id":id},
			    success:function(resp){
			    	var errcode = resp.errcode;
			    	if(errcode == 0){
			    		$("#myForm").fill(resp.data);
			    		$('#myModal').modal('show');
			    	}
			    }
			});
		}

		function doSubmit(){
			$('#myForm').ajaxSubmit({
				datatype : 'json',
				success : function(resp) {
					var resp = $.parseJSON(resp);
					if (resp.errcode == 0) {
						$('#myModal').modal('hide');
						_queryPage();
					} else {
						Modal.alert(resp.message);//失败提示
					}
				},
				error: function(){
					Modal.alert('保存失败');
	            }
			});
		}
	</script>

</@override>

<!-- extends 一定要写在页面最下方 -->
<@extends name="_base.html"/>
